package com.example.jack.community.view.me.collect;

import android.os.Bundle;
import android.support.percent.PercentRelativeLayout;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.example.jack.community.R;
import com.example.jack.community.data.me.Images;
import com.example.jack.community.view.me.collect.util.CollectAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class MyCollActivity extends AppCompatActivity {

    @BindView(R.id.img_back)
    ImageView imgBack;
    @BindView(R.id.txt_return)
    TextView txtReturn;
    @BindView(R.id.filla)
    PercentRelativeLayout filla;
    @BindView(R.id.activity_setting_icon)
    PercentRelativeLayout activitySettingIcon;
    @BindView(R.id.recycler)
    RecyclerView recycler;
    private List<Images> fruitList = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_coll);
        initFruits();
        ButterKnife.bind(this);

        LinearLayoutManager layout = new LinearLayoutManager(MyCollActivity.this);
        recycler.setLayoutManager(layout);
        final CollectAdapter adapter = new CollectAdapter(fruitList);
        recycler.setAdapter(adapter);


        adapter.setOnItemClickLitener(new CollectAdapter.OnItemClickLitener() {
            @Override
            public void onItemClick(View view, int position) {
                Toast.makeText(MyCollActivity.this, "这是条目" + position, Toast.LENGTH_LONG).show();
            }
        });
    }

    @OnClick({R.id.img_back, R.id.txt_return})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.img_back:
                finish();
                break;
            case R.id.txt_return:
                finish();
                break;
        }
    }

    private void initFruits() {
        for (int i = 0; i < 10; i++) {
            Images fruit = new Images(R.drawable.setting_a2);
            fruitList.add(fruit);
        }
    }
}
